var timer;
var ping = function () {
    const url = `/apiUser/revmessage/`;
    let regexp = /.*csrftoken=([^;.]*).*$/;
    let xCSRF = document.cookie.match(regexp) === null ? null : document.cookie.match(regexp)[1];
    let regexp_token = /.*jwtToken=([^;.]*).*$/;
    let token = document.cookie.match(regexp_token) === null ? null : document.cookie.match(regexp_token)[1];
    fetch(url, {
        method: 'GET',
        headers: {
            'token': token,
            'X-CSRFToken': xCSRF,
        },
    })
        .then(resp => resp.json())
        .then(json => {
            if (json.code !== 200) {
                Vue.prototype.$message({
                    message: `登录未验证 有些功能可能会受限哦`,
                    type: 'warning'
                });
                localStorage.removeItem('token');
                clearInterval(timer);
            } else {

            }
        })
}

ping();

timer = setInterval(
    ping, 1000 * 60
)

